package com.demo.excel;

import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author qingqing.liang
 * @create 2017-12-26
 **/
@Slf4j
public class Client {
    public static void main(String[] args) throws Exception {
        String fileName = "";
        String sheetName = "sheet名称";
        String[] titleArr = {"第1列","第2列","第三列"};
        String [] fieldNameArr = {"name","age","sex"};

        List<User4Excel> users  = new ArrayList<>();
        User4Excel user;
        for(int i=0;i<10000;i++){
            user = new User4Excel();
            user.setName("name" + i);
            user.setSex("male" + i);
            user.setAge(i);
            users.add(user);
        }

        Workbook wb = null;
        ExcelConfig config = ExcelConfig.builder().build();
        wb = ExcelUtil.export(config,sheetName,titleArr,users,fieldNameArr);

        OutputStream os = new FileOutputStream("testExcel.xlsx");
        wb.write(os);
        os.close();
        wb.close();
    }
}
